﻿<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="com.util.SuperString" %>
<%@ page import="com.util.SuperFile" %>
<%@ page import="com.util.SuperPage" %>
<%@ page import="java.util.*" %>
<%@ page import="com.mtbu.dao.DAOManager" %>
<%@ page import="com.mtbu.comm.Util" %>
<%@ page import="com.mtbu.bean.*"%>
<%session.setAttribute("cache","y");%>
<%@include file="sys_commcheck.jsp"%>
<%
	System.out.println("request:" + request.getRequestURI());
	System.out.println("request:" + SuperPage.getCurURL(request));

    String act = SuperString.notNullTrim(request.getParameter("act"));
    if(!act.equalsIgnoreCase("mod")) act = "add";
    boolean isAdd = act.equalsIgnoreCase("add");
    boolean isMod = act.equalsIgnoreCase("mod");
    String titletext = isAdd ? "新增" : "修改";

    String curFile = SuperPage.getCurURLFile(request);
    String modFileDo = SuperFile.getFileName(curFile) + "do.jsp";
    String curName = "STEP";

    int id = SuperString.getInt(request.getParameter("id"));
	int pid = SuperString.getInt(request.getParameter("pid"));
	//int pid = SuperString.getInt(request.getParameter("pid"));

    if(!isAdd && id <= 0 ) {
        Util.callInfo("错误的调用方法！", request, response);
        return;
    }

    Step record = isMod ? DAOManager.stepDao.findStep(id) : new Step();
    if(isMod && record==null){
        Util.callInfo("数据不存在！", request, response);
        return;
    }
    String strOnSubmit = SuperPage.getOnSubmitCode("", "");

	//List<Project> listPrj = DAOManager.projectDao.findAll();

	//Project project = DAOManager.projectDao.findProject(pid);
	System.out.println("record:" + record.getName());
	Project project =  isMod ? record.getProject() : DAOManager.projectDao.findProject(pid);;
	List<Step> listStep = project.getSteps();
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>无标题文档</title>
<link href="css/common.css" rel="stylesheet" type="text/css">
<script language="javascript" src="js/comm.js"></script>

<script type="text/javascript">
	function onSelect()
	{
		alert(13);
	}
</script>

</head>

<body>
<div class="title_text"><%=curName%>维护</div>

<div class="clear"><span/></div>

<table width="100%"  border="0" cellspacing="1" cellpadding="2">
  <tr>
    <td align="right"><input name="Submit22" type="button" class="BUTTON3" value="   返回上页   " onClick="history.go(-1);"></td>
  </tr>
</table>
<table width="100%" border="0" cellpadding="3" cellspacing="1" class="table_bord">
  <tr class="table_bord_ttl">
    <td><%=titletext+curName%></td>
  </tr>
  <tr class="tr_class1">
    <td><form name="form" method="post" action="<%=modFileDo%><%=SuperPage.getQueryQ(request,"")%>" <%=strOnSubmit%>>
    <table width="100%"  border="0" cellspacing="1" cellpadding="2">
      <tr>
        <td width="13%">&nbsp;</td>
        <td width="61%">&nbsp;</td>
        <td width="26%">&nbsp;</td>
      </tr>

      <tr>
        <td height="22" align="right">所属项目：</td>
        <td align="left">
			<%= project.getName() %>
		</td>
		<td>&nbsp;</td>
      </tr>
	  <tr>
	  	<td height="22" align="right">Type：</td>
		<td><input name="type" type="text" size="50" maxlength="255" id="key" value="<%=record.getType()%>" ></td>
		<td>&nbsp;</td>
	  </tr>
	  <tr>
	    <td height="22" align="right">名称：</td>
	    <td><input name="name" type="text" size="50" maxlength="255" id="key" value="<%=record.getName()%>" ></td>
	    <td>&nbsp;</td>
	  </tr>
	  <tr>
	    <td height="22" align="right">执行Bean：</td>
	    <td><input name="beanname" type="text" size="50" maxlength="255" id="key" value="<%=record.getBeanName()%>" ></td>
	    <td>&nbsp;</td>
	  </tr>

	  <tr>
		   <td height="22" align="right">上一流程：</td>
		   <td align="left">
			   <select name="prestepid" id="prestepid" >
				   <% for(int i = 0 ; i < listStep.size() ; i++) { %>
				   <% Step step = listStep.get(i);  %>
					   <option value="<%= step.getId() %>" <%= record.getPreStepId() == step.getId()  ? "selected " : "" %> >  <%= step.getName() %> </option>
				   <% } %>
				   <option value="0" <%= record.getPreStepId() == 0  ? "selected " : "" %>  > 无 </option>
			   </select>
		   </td>
		   <td>&nbsp;</td>
	  </tr>

	  <tr>
		   <td height="22" align="right">下一流程：</td>
		   <td align="left">
			   <select name="nextstepid" id="nextstepid" >
				   <% for(int i = 0 ; i < listStep.size() ; i++) { %>
				   <% Step step = listStep.get(i);  %>
					   <option value="<%= step.getId() %>" <%= record.getNextStepId() == step.getId()  ? "selected " : "" %> >  <%= step.getName() %> </option>
				   <% } %>
				   <option value="0" <%= record.getNextStepId() == 0  ? "selected " : "" %>  > 无 </option>
			   </select>
		   </td>
		   <td>&nbsp;</td>
	  </tr>
      <tr>
        <td align="center">&nbsp;</td>
        <td height="30">
		  <input name="Submit" type="submit" class="BUTTON2" value=" 提 交 ">
          <input name="Submit" type="button" class="BUTTON2" value=" 取 消 " onClick="history.back(1)"></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
	  </form></td>
  </tr>
</table>
<br>
</body>
</html>
